.\"	@(#)getgrent.3	6.1 (Berkeley) 5/15/85
.\"
.TH GETGRENT 3  "May 15, 1985"
.AT 3
.SH NAME
getgrent, getgrgid, getgrnam, setgrent, endgrent \- get group file entry
.SH SYNOPSIS
.nf
.B #include <grp.h>
.PP
.B struct group *getgrent()
.PP
.B struct group *getgrgid(gid)
.B int gid;
.PP
.B struct group *getgrnam(name)
.B char *name;
.PP
.B setgrent()
.PP
.B endgrent()
.fi
.SH DESCRIPTION
.I Getgrent,
.I getgrgid
and
.I getgrnam
each return pointers
to an object
with the following structure
containing the broken-out
fields of a line in the group file.
.RS
.PP
.nf
.so /usr/include/grp.h
.fi
.RE
.PP
The members of this structure are:
.TP \w'gr_passwd'u+2n
gr_name
The name of the group.
.br
.ns
.TP \w'gr_passwd'u+2n
gr_passwd
The encrypted password of the group.
.br
.ns
.TP \w'gr_passwd'u+2n
gr_gid
The numerical group-ID.
.br
.ns
.TP \w'gr_passwd'u+2n
gr_mem
Null-terminated vector
of pointers to the individual
member names.
.PP
.I Getgrent
simply reads the next
line while
.I getgrgid
and
.I getgrnam
search until a matching
.I gid
or
.I name
is found
(or until EOF is encountered).
Each routine picks up
where the others leave off
so successive calls may be used
to search the entire file.
.PP
A call to
.I setgrent
has the effect of rewinding
the group file
to allow
repeated searches.
.I Endgrent
may be called to
close the group file
when processing is complete.
.SH FILES
/etc/group
.SH "SEE ALSO"
getlogin(3), getpwent(3), group(5)
.SH DIAGNOSTICS
A null pointer
(0) is returned on EOF or error.
.SH BUGS
All information
is contained in a static area
so it must be copied if it is
to be saved.
